from jzb_caps import *
from appium.webdriver.common.touch_action import TouchAction
def swipe_to_up(driver):
    y1 = driver.get_window_size()['height'] * 0.3
    x1 = driver.get_window_size()['width'] * 0.5
    y2 = driver.get_window_size()['height'] * 0.7
    driver.swipe(x1, y2, x1, y1)
#返回主页面
driver.find_element(By.XPATH,'//android.view.View[@content-desc="返回"]').click()
#点击我的
driver.find_element(By.ID, 'com.mymoney:id/account_centre_icon_default_iv').click()
#下拉
swipe_to_up(driver)
#点击设置
driver.find_element(By.XPATH,
                    '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/androidx.viewpager.widget.ViewPager/androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.ScrollView/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView/android.widget.FrameLayout[9]/android.widget.LinearLayout/android.widget.LinearLayout').click()
#点击密码保护
driver.find_element(By.ID, 'com.mymoney:id/setting_right_tip').click()
#开启密码保护
driver.find_element(By.XPATH, '/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/android.view.ViewGroup/android.widget.Switch').click()
#点击手势密码
driver.find_element(By.ID, 'com.mymoney:id/ll_gesture_psd').click()
sleep(3)
#设置手势密码
TouchAction(driver).press(x=255, y=400).wait(2000).move_to(x=650, y=400).wait(2000).move_to(x=640, y=770).wait(
    1000).release().perform()
TouchAction(driver).press(x=255, y=400).wait(2000).move_to(x=650, y=400).wait(2000).move_to(x=640, y=770).wait(
    1000).release().perform()
#输入邮箱
driver.find_element(By.ID,'com.mymoney:id/email_eactv').send_keys('208028924@qq.com')
#确认邮箱
driver.find_element(By.ID,'com.mymoney:id/email_again_eactv').send_keys('208028924@qq.com')
#点击确定
driver.find_element(By.ID,'com.mymoney:id/ok_btn').click()